import java.io.File;
import java.util.HashMap;

public class test5 {
    static HashMap<String,Integer> hm = new HashMap<>();

    public static void main(String[] args) {
        File file = new File("E:\\test");
        getCount(file);
        hm.forEach((k,v)->System.out.println(k+":"+v));
    }

    public static void getCount(File file) {
        File[] files = file.listFiles();
        for(File f : files) {
            if(f.isDirectory()) {
                getCount(f);
            }
            else{
                String suffix = f.getName().substring(f.getName().lastIndexOf(".")+1);
                if(hm.containsKey(suffix)) {
                    hm.put(suffix,hm.get(suffix)+1);
                }else{
                    hm.put(suffix,1);
                }
            }
        }
    }
}
